package org.dfg.corejava.jdk8.stream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import org.dfg.corejava.jdk8.User;

/**
 * 顺序流和并行流
 */
public class StreamTest2 {
	public static void main(String[] args) {
		long t1 = System.nanoTime();

		IntStream.range(0, 100 - 0000).filter(p -> p % 2 == 0).toArray();
		long t2 = System.nanoTime();

		IntStream.range(0, 100 - 0000).parallel().filter(p -> p % 2 == 0).toArray();
		long t3 = System.nanoTime();

		System.out.println(t2 - t1);
		System.out.println(t3 - t2);// 快了一倍
	}

	public static void t1() {
		List<User> list = StreamTest.getList();
		List<User> l1 = list.stream().collect(Collectors.toList());// 顺序流
		List<User> l2 = list.stream().parallel().collect(Collectors.toList());// 并行流
	}
}
